<template>
	<view class="boxer">
		<view class="uni-page-head" v-if="titleFlag">
			<image class="common-title-img" style="left: 20rpx;"
				:src="require('../../static/imges/fanhui.png')" @click="fanhui()"></image>
			<view class="uni-page-head-title">
				解绑申请
			</view>
			<view style="width: 100rpx;height: 38rpx;position: absolute;right: 22rpx;top: 18rpx;color: white;font-size: 31rpx;font-weight:bold" >
				选择
			</view>
		</view>
		<view style="margin-top: 94rpx;">
		</view>
	    <view class="swiper-item">
			<view class="order" v-for="(item, index) in prjInfo" :key="index">
				<view>物料名称：<text :selectable="true">{{ item.prjName }}</text></view>
				<view class="type">物料编码：<text :selectable="true">{{ item.prjCode }}</text></view>
				<view class="type">标签ID：<text :selectable="true" style="color: #007AFF;"  @click="schemeert(key.resourceAssetCode,key.labelId)">{{ item.prjCode }}</text></view>
				<view class="type">资源资产编码：<text :selectable="true">{{ item.prjCode }}</text></view>
			</view>
	    	<!-- <scroll-view scroll-y style="height: 100%; width: 100%;" @scrolltolower="reachBottom">
	    		<view class="page-box" style="margin-bottom: 60px;">
	    			<view class="order" v-for="(item, index) in prjInfo" :key="index">
	    				<view>物料名称：<text :selectable="true">{{ item.prjName }}</text></view>
						<view class="type">物料编码：<text :selectable="true">{{ item.prjCode }}</text></view>
						<view class="type">标签ID：<text :selectable="true" style="color: #007AFF;"  @click="schemeert(key.resourceAssetCode,key.labelId)">{{ item.prjCode }}</text></view>
						<view class="type">资源资产编码：<text :selectable="true">{{ item.prjCode }}</text></view>
	    			</view>
	    		</view>
	    	
	    	</scroll-view> -->
	    </view>
	    <view class="buttonBox" >
	    	<button v-debounce="() => onOk(1)" type="warn" style="font-size: 30rpx;width: 200rpx">提交</button>
			<button @click="onOk(2)" type="warn"  plain="true" style="font-size: 30rpx;width: 200rpx;background-color: white;">取消</button>
	    </view>  
	</view>
</template>

<script>
	import ElectricCable from "./components/ElectricCable.vue";
	import { checkClickAbled } from "./utils";
	import { getGPS, exceedDistance } from "../utils/gpsUtil";
	export default {
	data() {
		return {
			dingwei:true,
			searchValue:'',
			searchValueer:'',
			show :false,
			show2: false,
			show3:false,
			show4:false,
			show5:false,
			loadStatus: ['loadmore', 'nomore','loadmore','loadmore'],
			prjInfo: [],
			border: true,
			mask: true, // 是否显示遮罩
			
			xiangmumingcheng:'',
			xiangmubianhao:'',
			zhanzhibianma:'',
			xiangmunianfen:'',
			xiangmujieduan:'',
			xiangmuleibie:'',
			prjStage:'',
			prjType:'',
			//zuo侧数据
		    fprjId:"",
			pageIndex:0,
			titleFlag:true,

		
		}
		}, 
		onLoad() {
			console.log("执行onLoad")
			if(uni.getStorageSync('moaType')=="0"){
					this.titleFlag=false
			}	
			 this.getList();
			
		},
		onShow() {
		  console.log("执行onShow");
		  getGPS("1","1",this.scanCodeInfo);
		},
		onReady(){
			console.log("执行onReady")
			
			//在页面挂载完成后，调用外部埋点，统计数据
			 // const script= document.createElement('script');
			 // script.type = 'text/javascript';
			 // script.src = talkingdata.talkingKey;
			 // document.body.appendChild(script);
			
		},
		methods: {
			// 跳转至经分系统
			schemeert(options,amger){
        this.$axios.get('/material/api/pub/material/getOtherSysIpAndPort',{ sysCode:'jingFenSysIpAndPort'}).then((res)=>{
          imp.iWindow.open({url:`${res.data}/api/user/getRedirectToBcsystem?resourceAssetCode=${options}&elabelNum=${amger}`})
        })
			},
			// 提交
			onOk(x){
				if(x==1){
					uni.showModal({
						title: '温馨提示',
						content: "确定要解绑吗？",
						showCancel:true,
              confirmColor: '#eb4b4b',
						success: function (res) {
								if (res.confirm) {
								 console.log('用户点击确定:');
								}
						}
					})
				}else{
            console.log('取消')
				}
			},
			// 获取经纬度
			scanCodeInfo(label, index, latitude, longitude){
				 console.log("获取经纬度");
				uni.setStorageSync("latitude",latitude);
				uni.setStorageSync("longitude",longitude);
			},
			fanhui() {
				
				uni.navigateBack({
					delta: 1
				});
			},

			reachBottom() {
				// 此tab为空数据
				console.log("分页触发")
				this.pageIndex += 10
				// setTimeout(() => {
				// 	this.getList();
				// }, 300);
				
			},
			getList() {
				console.log("出发"+this.searchValue)
				let latitude=uni.getStorageSync("latitude")/1;
				let longitude=uni.getStorageSync("longitude")/1;
				let latituder = parseFloat(latitude).toFixed(6);
				let longituder = parseFloat(longitude).toFixed(6);
				console.log("2,获取的经纬度：",latituder,longituder);
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				// this.params = "{'prjName':'" + this.searchValue +
				// 	"','prjCode':'" + this.xiangmubianhao +
				// 	"','beginNum':'" + this.pageIndex +
				// 	"','pageNum':'" + this.pageSize +
				// 	"'}";
				uni.request({
					url: uni.getStorageSync('url') + "/pms/app/complete/queryCompletedPrjList",
					method: 'POST',
					dataType: 'json',
					timeout: 10000 * 60,
					header: {
						'pmsToken': uni.getStorageSync('pmsToken')
					},
					data: {
						prjCode: this.xiangmubianhao,
						prjName: this.xiangmumingcheng,
						siteId: this.zhanzhibianma,
						beginNum:this.pageIndex,
						pageNum:"30",
						prjYear: this.xiangmunianfen,
						
						prjType: this.prjType,
						prjStage: this.prjStage,
						queryParm: this.searchValue,
						latitude:latituder,
						longitude:longituder
						//param: this.params
					},
					success: (res) => {
						uni.hideLoading();
						//console.log('获取项目列表数据:' + JSON.stringify(res));
						console.log('获取项目列表数据:', res.data);
						//console.log('URL:' + uni.getStorageSync('url') + url);
						var data = res.data;
						if (data.resultStat == "000") {
							
							if (0 == data.prjInfo.length) {
								this.showLoadMore = true; 
								
								uni.showModal({
									title: '温馨提示',
									content: "没有更多数据!",
									showCancel:false,
                    confirmColor: '#eb4b4b',
								})
							}
							// console.log('子数据:' + JSON.stringify(data.prjInfo));
							//console.log('111子数据:', data.prjInfo.some(item => item.distance == null));
							if(data.prjInfo.some(item => item.distance == null||item.distance == "0.00")){
								// uni.showModal({
								// 	title: '温馨提示',
								// 	content: "经纬度参数错误，请重新获取",
								// 	showCancel:false,
								// })
								this.dingwei=false;
							};
							this.prjInfo = this.prjInfo.concat(data.prjInfo);
							
						}else{
							uni.showModal({
								title: '温馨提示',
								content: JSON.stringify(data.message),
								showCancel:false,
                  confirmColor: '#eb4b4b',
							})
						}
						uni.hideLoading();
						uni.stopPullDownRefresh();
					},
					fail: (data, code) => {
						uni.hideLoading();
						uni.stopPullDownRefresh();
						console.log('fail' + JSON.stringify(data));
					}
				});
			},
		},
		}
</script>
<style>
	@import '@/common/common-ui.css';
	.u-search-box {
		padding: 18rpx 30rpx;
		background-color: #FFFFFF;
		display: flex;
		
	}
	
	.u-search-inner {
		background-color: rgb(204, 234, 234);
		width: 82%;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		padding: 10rpx 16rpx;
		background-color: white;
		border:solid 1px gray
	}
	
	.u-search-text {
		font-size: 26rpx;
		color: $u-tips-color;
		margin-left: 10rpx;
	}
	
	.l-label {
		margin-top: 5px;
		margin-left: 10px;
		color: #EB4B4B;
	}
	
	.l_count {
		display: flex;
		justify-content: space-around;
		margin-top: 8px;
	}
	
	.l_text {
		width: 80px;
		text-align: center;
	}
	
</style>
<style scoped lang="scss">
	.u-demo-area {
		
		margin: 0 -40rpx;
	}
	.swiper-item {
		height: 100%;
	    width: 100%;
		overflow: auto;
		padding-bottom: 100rpx;
	}
	.page-box{
		width: 100%;
		
	}
	.boxer{
		height: 100%;
		width: 100%;
	}
	.swiper-box {
		flex: 1;
		height: 100%;
		margin-top: 160rpx;
	}
	.order {
		width: 98%;
		background-color: #ffffff;
		margin: 10rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx;
		font-size: 28rpx;
	
		.top {
			display: flex;
			justify-content: space-between;
	        width: 100%;
			.left {
				display: flex;
				align-items: center;
	            
				.store {
					width: 90%;
					margin: 0 10rpx;
					font-size: 28rpx;
					font-weight: bold;
				}
			}
	
			.right {
				display: flex;
				justify-content: flex-end;
				min-width: 33%;
				//color: $u-type-warning-dark;
				.right-title{
					min-width: 170rpx;
					height: 50rpx;
					color: #eb4b4b;
					line-height: 50rpx;
					 text-align: center;
					border: 1px solid #eb4b4b;
					border-radius: 25rpx;
					font-weight: bold;
				}
			}
		}
	
		.item {
			display: flex;
			margin: 20rpx 0 0;
	
			.left {
				margin-right: 20rpx;
	
				image {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}
			}
	
			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}
	
				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}
	
				.delivery-time {
					color: #e5d001;
					font-size: 24rpx;
				}
			}
	
			.right {
				
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;
	
				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}
	
				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}
	
		
	
		
	}
	
	.bss-price-title-text {
		height: 48rpx;
		font-size: 40rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		/* color: #FFFFFF; */
		/* color: #FFFFFF; */
		line-height: 48rpx;
		text-align: left;
	}
	.close-btn {
		// height: 100%;
		margin-top: 50rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.buttonBox{
		position: fixed;
		bottom: 0;
		width: 100vw;
		display: flex;
		padding: 10rpx 0;
	}
	.selectBox{
		border: 1rpx solid #c0c4cc;
		position: absolute;
		width: 465rpx;
		z-index: 999;
		background-color: #FFFFFF;
		border-radius: 0 0 10rpx 10rpx;
		padding: 0 0 10px 0;
		
		.selectCell{
			border-bottom: 1rpx solid #FC8C8B;
			text-align: left;
			margin: 0 20rpx;
			font-size: 16px;
			color: #939393;
		}
	}
	.souSuoIcon{
		width: 100rpx;
		height: 74rpx;
		position: absolute;
		right: 33rpx;
		top: 68rpx;
		border-radius: 0 5px 5px 0;
		background: #FB5C5B;
		}
</style>
